const path = require("path")
const uglify = require('uglifyjs-webpack-plugin')
const htmlPlugin = require("html-webpack-plugin")
module.exports = {
    entry: {
        entry: './src/entry.js'
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].js'
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                // use: ["style-loader", "css-loader"], // 
                use: [{ //use的json格式编写
                    loader: 'style-loader'
                },{
                    loader: 'css-loader'
                }],
            },{
                test: /\.(png|jpg|gif)/,
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 500000
                    }
                }]
            },{
                test: /\.(htm|html)$/i,
                use: ['html-withimg-loader']
            },{
                test: /\.less$/,
                use: [{
                    loader: "style-loader"
                },{
                    loader: "css-loader"
                },{
                    loader: "less-loader"
                }]
            }
        ]
    },
    plugins: [
        // new uglify(),
        new htmlPlugin({
            minify: {
                removeAttributeQuotes: true
            },
            hash: true,
            template: './src/index.html'
        })
    ],
    devServer: {
        // 配置服务器基本运行路径，用于找到程序打包地址
        contentBase: path.resolve(__dirname, 'dist'),
         // 服务器运行地址，建议使用本机IP
        host: '192.168.1.88',
        // 服务器端压缩选型， 一般设置为开启。
        compress: true,
        // 配置运行端口，建议不使用80,很容易被占用，我这里使用1812
        port: 1812
    }
}